import { IFeidaoAiBrowserComponent } from '@dfeidao/atom-web/interfaces';

import nodejs from '@dfeidao/atom-web/msg/nodejs';
import render from '@dfeidao/atom-web/render/render';
import p004 from './p004';


export default async function a005(fd: IFeidaoAiBrowserComponent, e: Event) {
	// // todo
	// 更改传值
	// console.log(e);
	const div = e.currentTarget as HTMLDivElement;
	const no = div.getAttribute('data-no');
	// const name = div.getAttribute('data-name');
	// const arr=Array();
	// arr[0] = {
	// 	staff_no: no,
	// 	staff_name: name
	// };
	// render(fd, arr, p004, 'p004', 'lastin');
	// set(fd, 'arr', arr);
	// const d=e.currentTarget as HTMLInputElement;
	// const s=d.getAttribute('data-no');

	const div1 = fd.data.node.querySelectorAll<HTMLDivElement>('[data-id="vall"]');
	const res = await nodejs<Array<{ staff_no: string }>>('meeting-management/zj-000007/s003', {
		staff_no: no
	});
	const data = res.map((v) => {
		return { ...v, v: JSON.stringify(v) };
	});
	const arr1 = Array();
	for (let i = 0; i < div1.length; i++) {
		arr1.push(div1[i].getAttribute("data-no"));
	}
	let a = 0;
	for (let j = 0; j < div1.length; j++) {
		if (data[0].staff_no === arr1[j]) {
			a++;
		}
	}
	if (a === 1) {
		alert('已添加');
		return;
	} else {
		render(fd, data, p004, 'p004', 'lastin');
	}

}
